<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <script type="text/javascript" src="../script/config.js"></script>
    <style>

        .scheduling_a{
          margin:1.5rem;
          /*height:150px;*/
        }
        .scheduling_a_id_a{
          width:100%;
          /*height:40px;*/
          font-size:16px;
        }

        .scheduling_id{
            width:100%;
          color:#f16c3c;
        }
        .scheduling_name{
          height:30px;
          margin-top:10px;
          line-height:30px;
        }
        .scheduling_name,.scheduling_address,.scheduling_phone,.scheduling_to{
          line-height:30px;
        }
        .scheduling_to{
        color:#f16c3c;
        }
        .scheduling_line{
          height:0;
          width:100%;
          border-top:1px solid #d2d2d2;
          margin-top:10px;
        }
        .contact{
text-decoration:none;
 background-color:#f16c3c;
 border-radius:5px;
 margin-left:1rem;
 color:white;
 padding:5px;
        }
        .jiaofuqu{
          background-color:#f16c3c;
          border-radius:5px;
          margin-left:1rem;
          color:white;
        }
    </style>
</head>
<body>
    <!-- <div id="wrap" class="flex-wrap flex-vertical" >
        <header class="border-b" >
            <b tapmode="hover" onclick="api.closeWin();" class="ic-back"></b>
            <div class="title">历史单据</div>
          b tapmode="hover" onclick="funActionSheet();"  class="ic-check"></b>
        </header>
        <div id="main" class="flex-con" > -->
        <!-- <div class="scheduling_a">
           <div class="scheduling_a_id_a">
              <div class="scheduling_id">
                 清单号:<span>11280874598</span>

              </div>
              <div class="scheduling_to">
                <span style="padding-left:2rem;">南京</span>
                <img src="../image/arrows.png" style="width:10%;"/>
                <span>南通</span>
              </div>
              <div class="scheduling_name">
                收货单位/人：李二
              </div>
              <div class="scheduling_phone">
                联系电话：15862790779
              </div>
              <div class="scheduling_address">
                地址：武汉市
              </div>
              <div class="scheduling_line"></div>
           </div>
        </div>
        <div class="scheduling_a">
           <div class="scheduling_a_id_a">
              <div class="scheduling_id">
                 清单号:<span>11280874598</span>
              </div>
              <div class="scheduling_to">
                <span style="">南京</span>
                <img src="../image/arrows.png" style="width:10%;"/>
                <span>南通</span>
              </div>
              <div class="scheduling_name">
                收货单位/人：李二
              </div>
              <div class="scheduling_phone">
                联系电话：15862790779
              </div>
              <div class="scheduling_address">
                地址：武汉市
              </div>
              <div class="scheduling_line"></div>
           </div>
        </div> -->
        <!-- </div>
    </div> -->
</body>
</html>
<script type="text/javascript" src="../script/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    apiready = function(){
      var user = $api.getStorage('user');
      var lorryid=user.lorryid;
      var telephone=user.telephone;
      var time=user.time;
      // alert(user.lorryid)
         $api.get(url+'app.php/scnoaccept?lorry_id='+lorryid,function(ret){
     							if(ret.result==0){
                    api.toast({
                       msg: '成功',
                       duration: 1000,
                      location: 'middle'
                    });
                                  for(var i=0;i<ret.schedules.length;i++){
                                    var name=ret.schedules[i].customer_name;
                                    if(name.length>11){
                                      name=name.substring(0,11)+'...';
                                    }
                                    $api.append($api.dom('body'),'<div class="scheduling_a" id="c'+ret.schedules[i].scheduling_id+'">'+
                                                   '<div class="scheduling_a_id_a" id="d'+ret.schedules[i].scheduling_id+'">'+
                                                      '<div class="scheduling_id" id="e'+ret.schedules[i].scheduling_id+'">'+
                                                         '清单号:<span>'+ret.schedules[i].scheduling_id+'</span>'+
                                                      '</div>'+
                                                      '<div class="scheduling_to" id="f'+ret.schedules[i].scheduling_id+'">'+
                                                      '<span>'+ret.schedules[i].sendcity+'</span>'+
                                                      '<img src="../image/arrows.png" style="width:10%;"/>'+
                                                      '<span>'+ret.schedules[i].receivecity+'</span>'+
                                                      '</div>'+
                                                      '<div class="scheduling_name" id="g'+ret.schedules[i].scheduling_id+'">'+"收货单位/人："+name+'</div>'+
                                                      '<div class="scheduling_phone">'+"联系电话："+ret.schedules[i].customer_phone+'<a href="tel:'+ret.schedules[i].customer_phone+'" class="contact">联系Ta</a></div>'+
                                                      '<div class="scheduling_address" id="h'+ret.schedules[i].scheduling_id+'">'+"地址："+ret.schedules[i].address+'</div>'+
                                                      '<div class="scheduling_line"></div>'+
                                                   '</div>'+
                                                '</div>');
                                                $api.addEvt($api.dom("#e"+ret.schedules[i].scheduling_id), 'click', function(){
                                                  var did=$api.attr(this,'id').substring(1);
                                                  api.openWin({
                                                      name: 'scheduling_main_j',
                                                      url: './scheduling_main_j.html',
                                                      animation:{
                                                        type:"none",
                                                      },
                                                      pageParam: {
                                                          scheduling_id: did,
                                                     }
                                                  });
                                                  check(lorryid,time);
                                                });
                                                $api.addEvt($api.dom("#f"+ret.schedules[i].scheduling_id), 'click', function(){
                                                  var did=$api.attr(this,'id').substring(1);
                                                  api.openWin({
                                                      name: 'scheduling_main_j',
                                                      url: './scheduling_main_j.html',
                                                      animation:{
                                                        type:"none",
                                                      },
                                                      pageParam: {
                                                          scheduling_id: did,
                                                     }
                                                  });
                                                  check(lorryid,time);
                                                });
                                                $api.addEvt($api.dom("#g"+ret.schedules[i].scheduling_id), 'click', function(){
                                                  var did=$api.attr(this,'id').substring(1);
                                                  api.openWin({
                                                      name: 'scheduling_main_j',
                                                      url: './scheduling_main_j.html',
                                                      animation:{
                                                        type:"none",
                                                      },
                                                      pageParam: {
                                                          scheduling_id: did,
                                                     }
                                                  });

                                                  check(lorryid,time);
                                                });
                                                $api.addEvt($api.dom("#h"+ret.schedules[i].scheduling_id), 'click', function(){
                                                  var did=$api.attr(this,'id').substring(1);
                                                  api.openWin({
                                                      name: 'scheduling_main_j',
                                                      url: './scheduling_main_j.html',
                                                      animation:{
                                                        type:"none",
                                                      },
                                                      pageParam: {
                                                          scheduling_id: did,
                                                     }
                                                  });
                                                  check(lorryid,time);
                                                });
                                                // $api.addEvt($api.dom("a"), 'click', function(){
                                                //   setTimeout("api.closeToWin({name:'ordercc_main',animation:{type:'none',}})",700);
                                                // });
                                  }
     														 }else{
     															 alert(ret.desc);
     														 }
                            },'json');
                  };

var closewin1=function(){
   api.closeWin({
     name:'scheduling_main_j',
   });
}
var check=function(id,time){
  $api.post(url+'app.php/check',{
        body:{lorryid:id,
              time:time,}
       },function(ret){
        if(ret.result==4){
          alert(ret.desc);
          api.openWin({
            name: 'index',
            url:  '../index.html',
          });
           setTimeout("api.closeWin({name:'main'})",650);
           $api.rmStorage('password');
           var key = 'user';
           var user = {};
           var aa=$api.getStorage(key);
           user.lorryid=aa.lorryid;
            user.telephone=aa.telephone;
           user.flag= aa.flag
           user.pass= '';
           $api.setStorage(key, user);
           api.alert({
             title: '提示消息',
             msg: ret.desc,
             buttons: ['确定']
           });
         }else{
          //  alert(ret.desc);
         }
       });
}
</script>
